package com.example.shop.response;

import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlElementWrapper;
import java.util.ArrayList;
import java.util.List;

public class PageResponse<T> extends BaseResponse<PageResponse.PageResult<T>> {
    public PageResponse() {
    }

    @XmlAccessorType(XmlAccessType.FIELD)
    public static class PageResult<T> {

        @XmlElement(
                name = "pageIndex"
        )
        private int pageIndex;

        @XmlElement(
                name = "pageSize"
        )
        private int pageSize;

        @XmlElement(
                name = "total"
        )
        private int total;

        @XmlElementWrapper(
                name = "rows"
        )
        @XmlElement(
                name = "row"
        )
        private final List<T> rows = new ArrayList();

        public PageResult() {
        }

        public int getPageIndex() {
            return this.pageIndex;
        }

        public void setPageIndex(int pageIndex) {
            this.pageIndex = pageIndex;
        }

        public int getPageSize() {
            return this.pageSize;
        }

        public void setPageSize(int pageSize) {
            this.pageSize = pageSize;
        }

        public int getTotal() {
            return this.total;
        }

        public void setTotal(int total) {
            this.total = total;
        }

        public List<T> getRows() {
            return this.rows;
        }
    }
}
